<!DOCTYPE html>
<html class="pixel-ratio-1">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <title>{:getconfig('SITE_NAME')}</title>
    <meta name="keywords" content="">
    <meta name="description" content="">
    <!--    <link rel="stylesheet" href="__CSS__/sm.min.css">-->
    <link rel="stylesheet" href="__CSS__/weui.css">
    <link rel="stylesheet" href="__CSS__/example.css">
    <link rel="stylesheet" type="text/css" href="__CSS__/style.css">
</head>
<body ontouchstart="">
<div id="allmap" style="width: 0%;height: 0px;"></div>
<div class="container js_container">
    <div class="page" style="display:block;">
        <div class="hd" style="padding:0.5em;">
            <h1 class="page_title" style="font-size:1.5em;padding: 20px 0 30px 0;">
                <img height="70px" src="{:getconfig('SITE_LOGO')}"/>
            </h1>
        </div>
        <div class="bd">
            <div class="weui_cells weui_cells_form">
                <div class="weui_cells" style="margin-top: 0px;">
                    <div class="weui_cell" style="height:44px;padding:0 0 0 15px;">
                        <div class="weui_cell_hd"><label class="weui_label" style="width: 4em;">账号</label></div>
                        <div class="weui_cell_bd weui_cell_primary">
                            <input class="weui_input" name='phone' id="phone" type="number" pattern="[0-9]*"
                                   placeholder="请输入手机号"/>
                        </div>
                    </div>

                    <div class="weui_cell" style="height:44px;padding:0 0 0 15px;">
                        <div class="weui_cell_hd"><label class="weui_label" style="width: 4em;">密码</label></div>
                        <div class="weui_cell_bd weui_cell_primary">
                            <input name="keywords" class="weui_input" id="keywords" type="password" pattern="[6-60]*"
                                   placeholder="请填写登录密码"/>
                        </div>
                    </div>
                    <input type="hidden" name="user_isapp" value="2"/>
                    <div class="weui_cell" style="height:44px;padding:0 0 0 15px;">
                        <div class="weui_cell_hd"><label class="weui_label" style="width: 4em;">确认密码</label></div>
                        <div class="weui_cell_bd weui_cell_primary">
                            <input name="rekeywords" class="weui_input" id="rekeywords" type="password"
                                   pattern="[6-60]*" placeholder="请再次填写登录密码"/>
                        </div>
                    </div>
                    <div class="weui_cell" style="height:44px;padding:0 0 0 15px;">
                        <div class="weui_cell_hd"><label class="weui_label" style="width: 4em;">验证码</label></div>
                        <div class="weui_cell_bd weui_cell_primary">
                            <input style="width:60%;" name="smscode" class="weui_input" id="smscode" type="number"
                                   pattern="[6-60]*" placeholder="请输入短信验证码" value=""/>
                            <button class="code"
                                    style="line-height: 1.5rem;font-size: 1rem;float:right;color: #007aff;background: #fff;border: 0;width: 40%;"
                                    name="code2" href="javascript:" id="code2" onclick="code()">获取验证码
                            </button>
                        </div>
                    </div>
                </div>
                <div class="weui_cell">邀请码：{$id}</div>
                <input type="hidden" name="recommend" value="{$id}"/>
            </div>
            <div style="height: 40px; line-height:40px; margin-left: 10px; font-size: 12px;">
                <label for="reg_protocol">
                    <input type="checkbox" name="reg_protocol" id="reg_protocol" checked>
                    注册即表示您已同意<a href="{:Url('api/Main/protocol')}" target="_blank">《用户注册协议》</a>
                </label>

            </div>
            <div class="weui_btn_area">
                <a class="weui_btn weui_btn_primary js_grid" style="background: #007aff;width: 90%;" href="javascript:"
                   id="showTooltips">立即注册</a>
            </div>

            <div style="height: 20px;"></div>
            <div class="weui_btn_area">
                <a class="weui_btn weui_btn_primary "
                   style="background: #fff;width: 90%;border:0.5px solid #007aff ;color: #007aff; "
                   href="{:Url('Index/index/download')}" id="">下载地址</a>
            </div>
        </div>
    </div>
</div>
<input name="Longitude" id="Longitude" type="hidden" value=""/>
<input name="latitude" id="latitude" type="hidden" value=""/>

<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=SSFtLjfZA9eQTavnSK5fRot1k5rSDmaq"></script>
<!--<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=PlhFWpA02aoURjAOpnWcRGqw7AI8EEyO"></script>-->


<script type="text/javascript" src="__JS__/jquery-1.8.3.min.js"></script>
<script type="text/javascript" src="__JS__/mui.min.js"></script>
<script type="text/javascript">
    $(function () {
        //注册提交
        $("#showTooltips").click(function () {
            var chec = $('#reg_protocol').attr('checked');
            if (!chec) {
                mui.alert('请查看并勾选用户注册协议');
                return false;
            }
            var r = /^[1][3,4,5,6,7,8,9][0-9]{9}$/;
            if (!r.test($("#phone").val())) {
                mui.alert('请输入正确的手机号码');
                return false;
            }

            var data = {};
            var checked = true;
            $("input").each(function () {
                var value = $(this).val().trim();
                if (value == '' && $(this).attr('name') != "recommend") {
                    checked = false;
                    mui.alert($(this).attr('placeholder'));
                    $(this).focus();
                    return false;
                }
                data[$(this).attr('name')] = value;
            });
            //console.log(data);
            if (!checked) {
                return false;
            }
            $.post("/api/Main/register", data, function (e) {
                if (e.msg) {
                    mui.alert(e.msg);
                } else {
                    mui.alert("未知错误");
                }
                if (e.error == 0) {
                    location.href = "{:url('index/download')}";
                }
            });
        });
    });
    var flag = true;

    // 获取短信验证码
    function code() {
        var phoneNum = $("input[name='phone']").val();
        var r = /^[1][3,4,5,6,7,8,9][0-9]{9}$/;
        if (!r.test(phoneNum)) {
            mui.alert('请输入正确的手机号码');
            return false;
        }
        if (flag) {
            $.ajax({
                url: "{:Url('api/Main/getsms')}",
                type: "get",
                dataType: "json",
                data: {"phone": phoneNum, 'type': 1},
                timeout: 5000,
                success: function (data) {
                    //alert(window.mui);
                    if(window.mui){
                        mui.alert(data.msg);
                    }else{
                        alert(data.msg);
                    }

                    if (data.error == 1) {
                        return false;
                    } else {
                        var validCode = true;
                        var time = 60;
                        time--;
                        $('#code2').html(time + "S");
                        if (time == 0) {
                            $('#code2').removeAttr("disabled");
                            clearInterval(t);
                            $('#code2').html("重新获取");
                            validCode = true;
                        }
                        if (validCode) {
                            $('#code2').attr("disabled", "true");
                            validCode = false;
                            var t = setInterval(function () {
                                time--;
                                $('#code2').html(time + "S");
                                if (time == 0) {
                                    $('#code2').removeAttr("disabled");
                                    clearInterval(t);
                                    $('#code2').html("重新获取");
                                    validCode = true;
                                }
                            }, 1000)
                        }
                    }
                }

            })
        }
    }
</script>

<script type="text/javascript">
    // 百度地图API功能
    var map = new BMap.Map("allmap");
    var geoc = new BMap.Geocoder();
    var geolocation = new BMap.Geolocation();
    geolocation.getCurrentPosition(function (r) {
        if (this.getStatus() == BMAP_STATUS_SUCCESS) {
            var mk = new BMap.Marker(r.point);
            map.addOverlay(mk);
            map.panTo(r.point);
            $("#Longitude").val(r.point.lng);
            $("#latitude").val(r.point.lat);
            //console.log("当前位置经度为:" + r.point.lng + "纬度为:" + r.point.lat);
        } else {
            console.log('无法定位到您的当前位置，导航失败，请手动输入您的当前位置！' + this.getStatus());
        }
    }, {enableHighAccuracy: true});
</script>
</body>
</html>